# -*- coding:utf-8 -*-

# 1. 打印一个边长为N的正方形
"""
for i in range(6):
    print("10\t"*6)
    print("\t")

while True:
    for i in range(1,11):
        if i == 1 or i == 10:
            print('*'  * 21)
        else:
            print("*" + (' ' * 19) + "*")
    break
    
i = 0
while True:
    i += 1
    if (i==1) or (i==6):
        print("0"*6)
    else:
        print("o    o")
    if i==5:
        break
"""


# 2. 求100内所有奇数的和(2500)
"""
sum = 0
for i in range(1,100,2):
    sum += i
else:
    print(sum)

num = 0
for i in range(1,100):
    if i % 2 != 0:
        num += i

print(num)

# 求100内所有偶数的和
summ = 0
for i in range(1,100,2):
    summ += i+1
print(summ)
"""

# 3. 判断学生成绩,成绩等级A-E,其中,90分以上为'A',80~89分为'B',70~79分为'C',60~69分为'D',60分以下为'E'.
"""
num = int(input("请输入成绩:"))
if num >= 90:
    print("A")
elif 89 > num >= 80:
    print("B")
elif 79 > num >= 70:
    print("C")
elif 69 > num >= 60:
    print("D")
else:
    print("E")
"""

# 4. 求1到5阶乘之和
"""
num = 0
jc = 1
for j in range(5,0,-1):
    for i in range(5,0,-1):
        jc *= i
    num += jc
else:
    print(num)

n = int(input("请输入阶乘之和的数:"))
multiply = 1
sum = 0
for i in range(1,n*1):
    for j in range(1,i+1):
        multiply *= j
    sum += multiply
    multiply = 1
print(str(n)+"的阶乘之和为:",sum)
"""

# 5. 给一个数,判断它是否是素数(质数)
"""
num = 17

if num == 2:
    print("zhishu")
elif num > 2:
    for i in range(2,num):
        if num%i == 0:
            print('not zhishu')
            break
    else:
        print("zhishu")

m = int(input("please input number:"))
for i in range(2,m):
    if m%i == 0:
        print("No")
        break
else:
    print("yes")


# 
natural_number = int(input("请输入一个数,来判断它是否是素数:"))
for i in range(2,natural_number):
    if natural_number % i == 0:
        print(str(natural_number) + "不是素数")
        break
else:
    print(str(natural_number))

n = 34
i = 2
while i < n:
    if n % i == 0:
        print("is prime")
        break
    i += 1
else:
    print('not prime')


num = int(input("enter:"))

if num > 1:
    for i in range(2,num):
        if (num % i) == 0:
            break
        else:
            print("yes")
            exit()
print("no")
"""

# 6. 输入两个数,比较大小后,从小到大升序打印.
# 7. 给一个半径，求圆的面积和周长，圆周率3.14
# 8. 输入ｎ个数，求每次输入后的算数平均数

"""
# 6. 输入两个数,比较大小后,从小到大升序打印.
x = int(input("a:"))
y = int(input("b:"))

if x > y:
    print(x,y)
else:
    print(y,x)


# 7. 给一个半径，求圆的面积和周长，圆周率3.14
a = int(input('>>>'))
area = ('a**2)*3.14')
permiter = 2*a*3.14
print("面积：",area)
print("周长：",permiter)

# 8. 输入ｎ个数，求每次输入后的算数平均数
'''
count = 0
n = int(input("enter your number"))
sum = 0
for n in range(n):
    count += 1
    sum += n 
    ay = sum / count
    print(ay)
'''
n = int(input("请输入ｎ个数："))
count = 0
sum = 0
for i in range(1,n+1):
    x = int(input(">>>"))
    sum += x
    count += 1
    print(sum/count)
    break
"""

# 9. (完美答案)给一个半径，求圆的面积和周长，圆周率3.14
'''
r = int(input('r='))
print('area='+str(3.14*r*r))
print('circumference='+str(2*3.14*r))
'''
# 10. (完美答案)输入两个数,比较大小后,从小到大升序打印.
'''
a = input('first:')
b = input('second:')
if a > b:
    print(b,a)
else:
    print(a,b)
'''

# 11. 输入n个数,求每次输入后的算数平均数.
'''
n = 0
sum = 0
while True:
    i = input('>>>')
    if i == 'q':
        break
    n += 1
    sum += int(i)
    avg = sum/n
    print(avg)
'''

# 12. 打印九九乘法表
'''
for i in range(1,10):
    for j in range(1,i+1):
        print(i,'x',j,"=",i*j,end=' ')
    print()
'''
'''
for i in range(1,10):
    for n in range(1,i+1):
        print('%d*%d=%d'%(n,i,i*n),end=" ")
    print(" ")

for i in range(1,10): #循环到９
    for j in range(1,10): # 每行打印结果循环
        if j <= i: #判断打印区间
            print(j,"*",i,"=",j*i,end=" ")
    print(" ")
'''
'''
for i in range(1,10):
    for j in range(1,i+1):
        print(str(j) + '*' + str(i) + '=' + str(i*j) + '\t',end=' ')  # \t制表符．
    print(' ')

for i in range(10):
    b = 1
    while b <= i:
        print("{}*{} {} {:<4}".format(b,i,'=',b*i),end='')
        b += 1
    print()

for i in range(1,10):
    for j in range(1,i+1):
        print(str(j)+'*'+str(i)+"="+str(i*j),end=' ')
    print()
'''

'''
for i in range(1,10):
    for j in range(1,i+1):
        product = i * j 
        if j > 1 and product < 10:
            product = str(product) + ' '
        else:
            product = str(product)
        print(str(j)+'*'+str(i)+"="+product,end=' ')
    print()
'''
'''
for i in range(1,10):
    line = ''
    for j in range(1,i+1):
        line += '{0}*{1}={2}\t'.format(j,i,i*j)
    print(line)

for i in range(1,10):
    line = ''
    for j in range(1,i+1):
        line += '{0}*{1}={2:<2}　'.format(j,i,i*j)
    print(line)
# < 左对齐两个字符．　作方向使用．
# 　{2:<2}对应ｉ*j, :<2冒号是分割符号，＜表示左对齐，２表示宽度．
'''

# 倒序的九九乘法表
for i in range(1,10):
    line = ''
    for j in range(1,10):
        if i > j:
            line = '{} {} {:<4}'.format(' ',' ',' ')
        else:
            line = '{} * {} = {:<4}'.format(i,j,i * j)
        print(line,end = ' ')
    print()


# 已经听到马哥2018的46节课了．18.41分钟．




